<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <main id="app">
        <p>介绍：{{info}}</p>
        <p>firstName：{{firstName}}</p>
        <p>lastName：{{lastName}}</p>
        <input type="text" v-model.lazy="fullName">
    </main>
</body>
<script src="../vue.min.js"></script>
<script>
    new Vue({
        el: "#app",
        data() {
            return {
                firstName: "Hydra",
                lastName: "Feng",
                age: 35,
                sex: "男",
            }
        },
        computed: {
            info() {
                return `姓名：${this.fullName}，年龄：${this.age}，性别：${this.sex}`
            },
            fullName: {
                set(newVal) {
                    let arr = newVal.split(" ");
                    [this.firstName ,this.lastName ] = arr;
                },
                get() {
                    return this.firstName + " " + this.lastName;
                }
            }
        }
    })
</script>

</html>